import { createSlice } from '@reduxjs/toolkit'

const counterSlice = createSlice({
  name: 'counter',
  initialState: {
    counter: 99,
    message: 'hello world',
  },
  reducers: {
    incrementAction(state, { payload }) {
      state.counter += 1
    },
    decrementAction(state, { payload }) {
      state.counter -= 1
    },
    changeMessageAction(state, { payload }) {
      state.message = payload
    },
  },
})

export const { incrementAction, decrementAction, changeMessageAction } =
  counterSlice.actions

export default counterSlice.reducer
